<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{% if form.instance.pk %}编辑文章{% else %}新建文章{% endif %}</title>
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
            margin: 20px;
            background-color: #f5f5f5;
            color: #333;
        }
        .form-container {
            background: #fff;
            padding: 20px;
            border: 1px solid #ddd;
        }
        label {
            display: block;
            margin-top: 10px;
        }
        input[type="text"], textarea {
            width: 100%;
            padding: 10px;
            margin-top: 5px;
        }
        input[type="submit"] {
            margin-top: 20px;
            padding: 10px 20px;
            background: #0077cc;
            color: white;
            border: none;
            cursor: pointer;
        }
        input[type="submit"]:hover {
            background: #005fa3;
        }
        a {
            text-decoration: none;
            color: #0077cc;
            margin-left: 20px;
        }
        a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="form-container">
        <form method="post">
            {% csrf_token %}
            <label for="id_title">标题</label>
            <input type="text" id="id_title" name="title" value="{{ form.instance.title }}" required>
            <label for="id_author">作者</label>
            <input type="text" id="id_author" name="author" value="{{ form.instance.author }}" required>
            <label for="id_body">内容</label>
<textarea id="id_body" name="body" required rows="20">{{ form.instance.body }}</textarea>
            <input type="submit" value="{% if form.instance.pk %}保存更改{% else %}发布文章{% endif %}">
        </form>
        <a href="{% url 'post_list' %}">取消</a>
    </div>
</body>
</html>
